package com.xunji.xunji.module.account.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.huanxiao.base.base.BaseActivity;
import com.huanxiao.base.common.bean.EventMessage;
import com.huanxiao.base.view.SettingLayout;
import com.xunji.xunji.R;
import com.xunji.xunji.module.account.controller.UserAccount;

/**
 * Created by Paul on 2017/2/2.
 */

public class MyActivity extends BaseActivity implements View.OnClickListener {

    private SettingLayout slMaterial;
    private SettingLayout slAcheivement;
    private SettingLayout slMessage;
    private SettingLayout slDownload;
    private SettingLayout slFoot;
    private SettingLayout slOfflineMap;
    private SettingLayout slTrends;

    public static void start(Context context) {
        Intent starter = new Intent(context, MyActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my;
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    public void initBundleExtras(Bundle extras) {

    }

    @Override
    protected void initView() {
        slMaterial = fvById(R.id.sl_material);
        slAcheivement = fvById(R.id.sl_achievement);
        slMessage = fvById(R.id.sl_message);
        slDownload = fvById(R.id.sl_download);
        slFoot = fvById(R.id.sl_foot);
        slOfflineMap = fvById(R.id.sl_offline_map);
        slTrends = fvById(R.id.sl_trends);

    }

    @Override
    protected void initListener() {
        slMaterial.setOnClickListener(this);

        slAcheivement.setOnClickListener(this);

        slMessage.setOnClickListener(this);

        slDownload.setOnClickListener(this);
        slFoot.setOnClickListener(this);
        slOfflineMap.setOnClickListener(this);
        slTrends.setOnClickListener(this);

    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        UserAccount.getInstance().refreshUserInfo(null);
    }

    @Override
    protected boolean isBindEventBus() {
        return true;
    }

    @Override
    public void onEventBusListener(EventMessage message) {
        super.onEventBusListener(message);
        switch (message.getTag()){
            case EVENT_LOGIN:
                UserAccount.getInstance().refreshUserInfo(null);
                break;
        }

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.sl_material:
                if (UserAccount.getInstance().isLogin()) {
                    PersonalActivity.start(this);
                }else {
                    LoginActivity.start(this);
                }
                break;
            case R.id.sl_achievement:

                break;
            case R.id.sl_message:

                break;
            case R.id.sl_download:

                break;

            case R.id.sl_foot:
                MyTraceActivity.start(this);

                break;
            case R.id.sl_offline_map:

                break;

            case R.id.sl_trends:

                break;
        }
    }
}
